package org.xx.armory.swing.builders;

import java.util.ArrayList;
import java.util.List;

public class BoxLayoutModelBuilder
        extends LayoutModelBuilder<BoxLayoutModel>
        implements ContainerModelBuilder {
    private final List<ComponentModel> children;
    private ModelAlignment horizontalAlignment;
    private ModelAlignment verticalAlignment;
    private int axis;

    public BoxLayoutModelBuilder() {
        this.children = new ArrayList<>();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BoxLayoutModelBuilder addChild(
            ComponentModel child
    ) {
        this.children.add(child);
        return this;
    }

    public final BoxLayoutModelBuilder setHorizontalAlignment(
            ModelAlignment horizontalAlignment
    ) {
        this.horizontalAlignment = horizontalAlignment;
        return this;
    }

    public final BoxLayoutModelBuilder setVerticalAlignment(
            ModelAlignment verticalAlignment
    ) {
        this.verticalAlignment = verticalAlignment;
        return this;
    }

    public final BoxLayoutModelBuilder setAxis(
            int axis
    ) {
        this.axis = axis;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BoxLayoutModel build() {
        return new BoxLayoutModel(getLineInfo(), getName(), isVisible(), getTitle(), getBorder(),
                                  this.horizontalAlignment, this.verticalAlignment, this.axis, this.children);
    }
}
